<template>
  <div class="container" v-loading="loading">
    <el-carousel :interval="4000" type="card" height="300px">
      <el-carousel-item v-for="item in img_list" :key="item.dishId">
        <h3 class="medium">
          <router-link :to="{
              name:'detail',
              params:{
                  id: item.id
		        }
             }"><img :src="item.url" alt="" class="imgs"/></router-link>
        </h3>
      </el-carousel-item>
    </el-carousel>
    <div class="slider-three leftfix" v-for="(dish, index) in coldDishes" :key="dish.id">
      <div class="slider-wrapper-three">
        <router-link :to="{
              name:'detail',
              params:{
                  id:dish.id
              }
             }"><img :src="require('../Home/images/'+dish.dishUrl)" alt="" style="width: 275px;height: 150px;"/></router-link>
      </div>
      <div class="slider-footer">
        <p>{{ dish.dishName }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  data() {
    return {
      img_list: [
        {"id": 12, "name": "皮蛋拌豆腐", "url": require("@/pages/Home/images/皮蛋拌豆腐.jpg")},
        {"id": 22, "name": "风干腊鱼", "url": require("@/pages/Home/images/风干腊鱼.jpg")},
        {"id": 23, "name": "花生拌紫美人萝卜", "url": require("@/pages/Home/images/花生拌紫美人萝卜.jpg")},
        {"id": 24, "name": "捞汁大虾", "url": require("@/pages/Home/images/捞汁大虾.jpg")},
      ],
      coldDishes: [],
      loading : true
    }
  },
  mounted() {
    request.get('dish/hotDishes/2')
        .then(res => {
          if (res.data.code == 1) {
            this.coldDishes = res.data.data
            this.loading = false
          }
        })
        .catch(err => {
          console.log(err)
        })
  }
}
</script>

<style scoped>
.container {
  width: 1160px;
  margin: 0 auto;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}

.slider-three {
  width: 275px;
  height: 195px;
  overflow: hidden;
  margin-left: 15px;
  margin-bottom: 20px;
  margin-top: 20px;
}

.slider-wrapper-three {
  width: 100%;
  height: 150px;
}

.slider-footer {
  height: 80px;
  background-color: rgb(100, 67, 68);
  padding: 12px 12px 0 12px;
  position: relative;
  line-height: 25px;
  text-align: center;
  color: white;
}

.imgs {
  width: 580px;
  height: 300px;
}
</style>
